package com.heima.dome1;

import com.heima.domain.Student;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class lianxi7 {
    public static void main(String[] args) {
        Map<Student,String> map = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result = o1.compareTo(o2);
                return result;
            }
        });

        Student s1 = new Student("zhangsan",19,99);
        Student s2 = new Student("lisi",12,99);
        Student s3 = new Student("wangwu",11,88);

        map.put(s1,"lilin");
        map.put(s2,"zhuzhou");
        map.put(s3,"changgsha");

        Set<Map.Entry<Student, String>> entries = map.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            System.out.println(entry.getKey()+"-"+entry.getValue());
        }
    }

}
